import { request } from '../request';

/** 获取工单列表 */
export function fetchGetTicketList(data?: TicketManageApi.TicketManage.TicketSearchParams) {
  return request<TicketManageApi.TicketManage.TicketList>({
    url: '/api/v1/ticket',
    method: 'get',
    params: data
  });
}

/** 获取设备列表 */
export function fetchGetDeviceList(data?: TicketManageApi.DeviceManage.DeviceSearchParams) {
  return request<TicketManageApi.DeviceManage.DeviceList>({
    url: '/api/v1/device',
    method: 'get',
    params: data
  });
}

/** 获取设备列表 */
export function fetchGetDeviceDetail(data: TicketManageApi.DeviceManage.DeviceDetailParams) {
  return request<TicketManageApi.DeviceManage.Device>({
    url: `/api/v1/device/mac/${data}`,
    method: 'get'
  });
}

/** 获取量子配置列表 */
export function fetchGetVPNList(data?: TicketManageApi.VPNManage.VPNSearchParams) {
  return request<TicketManageApi.VPNManage.VPNList>({
    url: '/api/v1/ipsec',
    method: 'get',
    params: data
  });
}

/** 新建量子配置 */
export function fetchAddVPN(data: TicketManageApi.VPNManage.AddVPNParams) {
  return request({
    url: '/api/v1/ipsec',
    method: 'post',
    data
  });
}

/** 编辑量子配置 */
export function fetchEditVPN(data: TicketManageApi.VPNManage.EditVPNParams) {
  return request({
    url: `/api/v1/ipsec/${data.id}`,
    method: 'put',
    data
  });
}

/** 删除量子配置 */
export function fetchDeleteVPN(data: TicketManageApi.VPNManage.DeleteVPNParams) {
  return request({
    url: '/api/v1/ipsec',
    method: 'delete',
    data
  });
}

/** 量子配置详情 */
export function fetchVPNDetail(data: TicketManageApi.VPNManage.VPNDetailParams) {
  return request<TicketManageApi.VPNManage.VPNDetail>({
    url: `/api/v1/ipsec/${data}`,
    method: 'get',
    data
  });
}

/** 获取量子模板配置列表【不分页】 */
export function fetchGetAllVPNTemplateList() {
  return request<TicketManageApi.VPNTemplateManage.Template[]>({
    url: '/api/v1/ipsec/template/all',
    method: 'get'
  });
}

/** 获取量子模板配置列表 */
export function fetchGetVPNTemplateList(data?: TicketManageApi.VPNTemplateManage.TemplateSearchParams) {
  return request<TicketManageApi.VPNTemplateManage.TemplateList>({
    url: '/api/v1/ipsec/template',
    method: 'get',
    params: data
  });
}

/** 新建量子模板配置 */
export function fetchAddVPNTemplate(data: TicketManageApi.VPNTemplateManage.AddTemplateParams) {
  return request({
    url: '/api/v1/ipsec/template',
    method: 'post',
    data
  });
}

/** 编辑量子模板配置 */
export function fetchEditVPNTemplate(data: TicketManageApi.VPNTemplateManage.EditTemplateParams) {
  return request({
    url: `/api/v1/ipsec/template/${data.id}`,
    method: 'put',
    data
  });
}

/** 删除量子模板配置 */
export function fetchDeleteVPNTemplate(data: TicketManageApi.VPNTemplateManage.DeleteTemplateParams) {
  return request({
    url: `/api/v1/ipsec/template`,
    method: 'delete',
    data
  });
}

/** 量子模板配置详情 */
export function fetchVPNTemplateDetail(data: TicketManageApi.VPNTemplateManage.TemplateDetailParams) {
  return request<TicketManageApi.VPNTemplateManage.Template>({
    url: `/api/v1/ipsec/template/${data}`,
    method: 'get'
  });
}
